home *** CD-ROM | disk | FTP | other *** search
/ Scene Storm / Scene Storm - Volume 1.iso / coding / c / amiexpress / source / ae / xpr.s < prev   
Encoding:
Text File  |  1980-01-03  |  16.9 KB  |  704 lines

  1.         opt    o+,ow6-,w+,c+,l+,p=68020,autopc
  2.  
  3.         xref    _DOSBase        /* DOS lib base */
  4.         xref    _myxprunit
  5.         xref    _myxprdevice
  6.         xref    _xprinit
  7.         xref    _protocol
  8.         xref    _sendopt
  9.         xref    _SendPath
  10.         xref    _ReceivePath
  11.         xref    _DTBT
  12.         xref    _TBT
  13.         xref    _TTTM
  14.         xref    _TTEFF
  15.         xref    _TTCPS
  16.         xref    _Online_NFiles
  17.         xref    _BatchXfer
  18.         xref    _Time_limit
  19.         xref    _Time_hrs
  20.         xref    _Time_mins
  21.         xref    _Time_secs
  22.                 
  23.         xdef    _xprsequence        ;XPR Protocol Send/Recieve
  24.  
  25. *******************************************************************************
  26. * XPR-Callback Interface
  27. * ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
  28. * Written for the Ami-Express /X3.xx Series,
  29. * Based around some very old (badly written) example "IntXpr.asm" source.
  30. *
  31. * Copyright © 1993-94. All Rights Are Reserved.
  32. *******************************************************************************
  33.  
  34.         cnop    0,4
  35. _xprsequence:    movem.l    d0-d7/a0-a6,-(sp)
  36.  
  37. call_back:    lea    cb(pc),a5        ;pc-relativity base
  38. cb:        move.l    _DOSBase(a4),DOSBase-cb(a5)    ;save base address of dos
  39.         move.l    a4,DTBase-cb(a5)        ;save offset base
  40.  
  41.         lea    relocflag(pc),a0
  42.         tst.w    (a0)
  43.         beq.s    reloc_done
  44.  
  45.         clr.w    (a0)+
  46.         lea    17*4(a0),a1
  47.         moveq    #23-1,d0
  48. reloc:        move.l    (a0),d1
  49.         beq.s    relocskip
  50.         add.l    a0,d1
  51. relocskip:    move.l    d1,(a0)+
  52.         dbra    d0,reloc
  53.  
  54.         moveq    #4,d0
  55.         move.l    d0,(a1)
  56. reloc_done:
  57.  
  58. ;-------------- Open XPR Library (eg; XPRZModem.library') ---------------------
  59.  
  60.         move.l    4.w,a6            ;get execbase
  61.         move.l    _protocol(a4),a1    ;name of XPR library to open
  62.         jsr    _LVOOldOpenLibrary(a6)    ;open any version XPR Library
  63.         move.l   d0,XPRBase-cb(a5)    ;save base address of XPR
  64.         beq.w    XPRFailed        ;fail? ELSE we`ve got a base...
  65.  
  66. ;-------------- Open Serial Device --------------------------------------------
  67.  
  68.         lea     SerIO(pc),a1        ;IOExtSer Structure
  69.         moveq    #0,d0            ;clear d0
  70.         move.l    d0,d1            ;clear d1
  71.         move.b    _myxprunit(a4),d0    ;d0=XPR Unit
  72.         move.b    #$B4,IO_SERFLAGS(a1)    ;set radboogie,7wire,(shared=b4)
  73.         move.l    _myxprdevice(a4),a0    ;exclusive = $94
  74.         jsr    _LVOOpenDevice(a6)    ;open xprdevice
  75.             tst.l   d0            ;did it fail?
  76.             bne.w    XPRFailed        ;if=0 it opened fine,else error
  77.  
  78. ;-------------- Add Serial ReplyPort ------------------------------------------
  79.  
  80.         suba.l  a1,a1            ;no task name... we want this
  81.         jsr    _LVOFindTask(a6)    ;find 'This task'
  82.         lea     SerReply(pc),a1
  83.         move.l  d0,MP_SIGTASK(a1) 
  84.         jsr    _LVOAddPort(a6)        ;add a reply (message-)port
  85.         lea     SerIO(pc),a1        ;replyport eintragen
  86.         lea    SerReply(pc),a0
  87.         move.l    a0,MN_REPLYPORT(a1)
  88.  
  89. ;-------------- Open Timer.Device ---------------------------------------------
  90.  
  91.         lea    timer_name(pc),a0    ;ptr to 'timer.device' string
  92.         lea    TimeIO(pc),a1        ;ptr to our TimeIO structure
  93.         moveq    #UNIT_MICROHZ,d0    
  94.         moveq    #0,d1
  95.         jsr    _LVOOpenDevice(a6)    ;open 'timer.device'
  96.         tst.l    d0
  97.         bne.s    CloseSerial
  98.         
  99. ;-------------- Add TimerIO Message ReplyPort ---------------------------------
  100.  
  101.         suba.l  a1,a1            ;this task
  102.         jsr    _LVOFindTask(a6)    ;find our task
  103.         lea     TimeReply(pc),a1
  104.         move.l  d0,MP_SIGTASK(a1)    ;save taskadr into sigtask
  105.         jsr    _LVOAddPort(a6)
  106.         lea    TimeIO(pc),a1        ;replyport
  107.         lea    TimeReply(pc),a0
  108.         move.l    a0,MN_REPLYPORT(a1)
  109.  
  110. ;-------------- Call our 'XPR-Transfer Routines' ------------------------------
  111.  
  112.         moveq    #0,d0
  113.         move.l    d0,_DTBT(a4)                 ;clear xfer stats
  114.         move.l    d0,_TBT(a4)
  115.         move.l    d0,_TTTM(a4)
  116.         move.l    d0,_TTEFF(a4)
  117.         move.l    d0,_TTCPS(a4)
  118.         move.l    d0,_Online_NFiles(a4)
  119.  
  120.         move.l    d0,TmpCps-cb(a5)
  121.         move.l    d0,TmpEff-cb(a5)
  122.         move.l    d0,TmpTim-cb(a5)
  123.         move.l    d0,TmpSiz-cb(a5)
  124.  
  125. ;-------------- Begin XPR-Transfer --------------------------------------------
  126.  
  127.         bsr.b    XPRTransfer
  128.  
  129. ;/* [ShutDown] ***************************************************************/
  130.  
  131. CloseTimer:    move.l    4.w,a6            ;get execbase
  132.         lea    TimeIO(pc),a1        ;ptr to TimerIO Structure
  133.         jsr    _LVOCloseDevice(a6)    ;Close Timer Device
  134.         lea    TimeReply(pc),a1    ;ptr to TimeReply Structure
  135.         jsr    _LVORemPort(a6)        ;remove TimerIO ReplyPort
  136.  
  137. CloseSerial    move.l    4.w,a6            ;get execbase
  138.         lea      SerIO(pc),a1        ;ptr to SerialIO Structure
  139.         jsr    _LVOCloseDevice(a6)    ;Close Serial Device
  140.         lea      SerReply(pc),a1    ;ptr to Serial ReplyPort
  141.         jsr    _LVORemPort(a6)        ;remove Serial ReplyPort
  142.  
  143. CloseXPRLib    lea    cb(pc),a5
  144.         move.l    4.w,a6            ;get execbase
  145.         move.l    XPRBase(pc),d0        ;base of library to close
  146.         beq.s    XPRFailed
  147.         clr.l    XPRBase-cb(a5)
  148.         move.l    d0,a1
  149.         jsr    _LVOCloseLibrary(a6)    ;close the library
  150.  
  151. XPRFailed    movem.l    (sp)+,d0-d7/a0-a6
  152.         rts
  153.  
  154.  
  155. ;/* [Transfer] ***************************************************************/
  156.  
  157.         cnop    0,4
  158. XPRTransfer:    tst.b    _sendopt(a4)
  159.         bne.s    Send
  160.  
  161. Receive:    lea    XPR_IO(pc),a0
  162.         move.l    _xprinit(a4),(a0)
  163.         move.l    XPRBase(pc),a6
  164.         jsr      -36(a6)        ;_LVOSetup (general params)
  165.  
  166.         move.l    a4,-(sp)
  167.         move.l    DTBase(pc),a4
  168.         move.l    _ReceivePath(a4),a2
  169.         move.l    (sp)+,a4
  170.  
  171.         move.b   #"P",(a2)
  172.         lea      XPR_IO(pc),a0
  173.         move.l   a2,(a0)
  174.         jsr      -36(a6)        ;_LVOSetup (receive path)
  175.         lea      XPR_IO(pc),a0
  176.         jsr      -48(a6)        ;_LVOReceive
  177.                lea      XPR_IO(pc),a0
  178.         jmp      -30(a6)        ;_LVOCleanup
  179.  
  180. Send        lea    XPR_IO(pc),a0
  181.         move.l    _xprinit(a4),(a0)
  182.         move.l    XPRBase(pc),a6
  183.         jsr    -36(a6)            ;Setup general params
  184.  
  185.         move.l    a4,-(sp)
  186.         move.l    DTBase(pc),a4
  187.         move.l    _SendPath(a4),a1            
  188.         move.l    (sp)+,a4
  189.  
  190.         lea    XPR_IO(pc),a0
  191.         move.l    a1,(a0)            ;give pointer to ffirst/fnext
  192.         jsr    -42(a6)            ;Send
  193.         lea     XPR_IO(pc),a0
  194.         jmp     -30(a6)            ;Cleanup
  195.  
  196.         cnop    0,4
  197. AddTmps:    move.l    a4,-(sp)
  198.         move.l    d0,-(sp)
  199.         move.l    DTBase(pc),a4
  200.         move.l    TmpCps(pc),d0
  201.         add.l    d0,_TTCPS(a4)
  202.         move.l    TmpEff(pc),d0
  203.         add.l    d0,_TTEFF(a4)
  204.         move.l    TmpTim(pc),d0
  205.         add.l    d0,_TTTM(a4)
  206.      
  207.         move.b    _sendopt(a4),d0
  208.         beq.s    noRecSize
  209.         move.l    TmpSiz(pc),d0
  210.         add.l    d0,_TBT(a4)
  211.         moveq    #1,d0
  212.         add.l    d0,_Online_NFiles(a4)
  213. noRecSize    move.l    (sp)+,d0
  214.         move.l    (sp)+,a4
  215.  
  216. ResetTmps:    move.l    a5,-(sp)
  217.         lea    cb(pc),a5
  218.         clr.l    TmpCps-cb(a5)
  219.         clr.l    TmpEff-cb(a5)
  220.         clr.l    TmpTim-cb(a5)
  221.         clr.l    TmpSiz-cb(a5)
  222.         move.l    (sp)+,a5
  223.         rts
  224.  
  225. ;/* [xpr_fopen] *************************************************************/
  226. ;/*                                        */
  227. ;/* $Outputs:    a0.l = char *filename                        */
  228. ;/*        a1.l = char *accessmode                        */
  229. ;/*                                        */
  230.         cnop    0,4
  231. xpr_fopen:    move.l    DOSBase(pc),a6
  232.         move.l  a0,d1
  233.         move.b    (a1),d0
  234.         bclr    #5,d0        ;cap. letters
  235.         cmpi.b    #"R",d0
  236.         bne.b    noMODE_READ
  237.         move.l    #MODE_OLDFILE,d2
  238.         jmp    _LVOOpen(a6)        ;d1^name d2=mode
  239.  
  240.         cnop    0,4
  241. noMODE_READ    cmpi.b    #"W",d0
  242.         bne.b    noMODE_WRITE
  243.         move.l    #MODE_NEWFILE,d2
  244.         jmp    _LVOOpen(a6)        ;d1^name d2=mode
  245.  
  246.         cnop    0,4
  247. noMODE_WRITE    cmpi.b    #"A",d0
  248.         bne.b    noMODE_APPEND
  249.         move.l    d1,d5           ;save ^name
  250.         move.l    #MODE_OLDFILE,d2
  251.         jsr    _LVOOpen(a6)
  252.             tst.l    d0
  253.             bne.b    OPENok
  254.         move.l    d5,d1
  255.             move.l    #MODE_NEWFILE,d2
  256.         jmp    _LVOOpen(a6)
  257.  
  258.         cnop    0,4
  259. OPENok        move.l     d0,d5        ;save handle
  260.         move.l   d0,d1        ;goto end of file (append)
  261.         moveq    #0,d2
  262.         moveq    #OFFSET_END,d3
  263.         jsr    _LVOSeek(a6)
  264.         move.l     d5,d0        ;handle in d0 must be returned
  265.         rts
  266.  
  267.         cnop    0,4
  268. noMODE_APPEND    moveq    #0,d0
  269.         rts            ;do nothing
  270.  
  271.  
  272. ;/* [xpr_fclose] ************************************************************/
  273. ;/*                                        */
  274. ;/* $Outputs:    a0.l = char *filepointer                    */
  275. ;/*                                        */
  276.  
  277.         cnop    0,4
  278. xpr_fclose    move.l    a0,d1
  279.         move.l    DOSBase(pc),a6
  280.         jsr    _LVOClose(a6)
  281.         bra.w    AddTmps
  282.  
  283. ;/* [xpr_fread] *************************************************************/
  284. ;/*                                        */
  285. ;/* $Outputs:    a0 = char *buffer                        */
  286. ;/*         d0 = long *size                            */
  287. ;/*         d1 = long *count                        */
  288. ;/*         a1 = long fileptr                        */
  289. ;/*                                        */
  290.  
  291.         cnop    0,4
  292. xpr_fread    move.l    d1,d3            ;length
  293.         move.l    a0,d2            ;buffer
  294.         move.l    a1,d1            ;file-handle
  295.         move.l    DOSBase(pc),a6
  296.         jmp    _LVORead(a6)
  297.  
  298. ;/* [xpr_fwrite] ************************************************************/
  299. ;/*                                        */
  300. ;/* $Outputs:    a0 = char *buffer                        */
  301. ;/*         d0 = long *size                            */
  302. ;/*         d1 = long count                            */
  303. ;/*         a1 = long fileptr                        */
  304.         cnop    0,4
  305.  
  306. xpr_fwrite    move.l    d1,d3            ;length
  307.         move.l    a0,d2            ;buffer
  308.         move.l    a1,d1            ;file-handle
  309.         move.l    DOSBase(pc),a6
  310.         jmp    _LVOWrite(a6)
  311.  
  312. ;/* [xpr_squery] ************************************************************/
  313. ;/*                                        */
  314. ;/* $Outputs:    None (void)                            */
  315.  
  316.         cnop    0,4
  317. xpr_squery    lea    SerIO(pc),a1
  318.         move.w    #SDCMD_QUERY,IO_COMMAND(a1)
  319.         move.l    4.w,a6
  320.         jsr    _LVODoIO(a6)
  321.         lea    SerIO(pc),a1
  322.         move.l    IO_ACTUAL(a1),d0
  323.         rts
  324.  
  325. ;/* [xpr_sread] *************************************************************/
  326. ;/*                                        */
  327. ;/* $Outputs:    a0 = char *buffer                        */
  328. ;/*         d0 = long size                            */
  329. ;/*         d1 = long timeout                        */
  330.  
  331.         cnop    0,4
  332. xpr_sread    lea    cb(pc),a1
  333.         move.l    a0,IO_DataPt-cb(a1)    ;IO_DATA
  334.         move.l    d0,IO_Size-cb(a1)    ;IO_LENGTH
  335.         move.l    d1,IO_TimeOut-cb(a1)    ;timeout or 0
  336.         bne.s    wantsTIMEOUT
  337.  
  338.         bsr.s    xpr_squery
  339.         tst.l    d0
  340.         beq.s    read_done
  341.  
  342.         lea    SerIO(pc),a1
  343.         move.w    #CMD_READ,IO_COMMAND(a1)
  344.         move.l    IO_DataPt(pc),IO_DATA(a1)
  345.         move.l    IO_Size(pc),IO_LENGTH(a1)
  346.         cmp.l    IO_Size(pc),d0
  347.         bcc.s    read_ok            ;more than asked for?
  348.         move.l    d0,IO_LENGTH(a1)
  349. read_ok:    move.l    4.w,a6
  350.         jsr    _LVODoIO(a6)
  351.         move.l    IO_ACTUAL(a1),d0
  352. read_done:    rts            ;return with count=0
  353.  
  354.         cnop    0,4
  355. wantsTIMEOUT:    lea    SerIO(pc),a1
  356.         move.w    #CMD_READ,IO_COMMAND(a1)
  357.         move.l    IO_Size(pc),IO_LENGTH(a1)
  358.         move.l    IO_DataPt(pc),IO_DATA(a1)
  359.         move.l    4.w,a6
  360.         jsr    _LVOSendIO(a6)        ;DoIO would not return
  361.  
  362.         lea    TimeIO(pc),a1
  363.         move.w    #TR_ADDREQUEST,IO_COMMAND(a1)
  364.         move.l    IO_TimeOut(pc),$24(a1)    ;timeout in microsecs
  365.         clr.l    $20(a1)            ;0 secs
  366.         jsr    _LVOSendIO(a6)
  367.  
  368. noTIMER            lea    SerReply(pc),a1        ;generate waitmaske
  369.         moveq    #0,d0            ;wait: either asked # of bytes arrive or
  370.         move.l    d0,d1            ;timerequest returns (timeout)
  371.             move.b    MP_SIGBIT(a1),d1
  372.         bset.l    d1,d0
  373.         lea    TimeReply(pc),a1
  374.         move.b    MP_SIGBIT(a1),d1
  375.         bset    d1,d0
  376.         move.l    4.w,a6
  377.         jsr    _LVOWait(a6)        ;timeout!enough_bytes
  378.  
  379.         lea    SerIO(pc),a1        ;ok, iam back who signaled me?
  380.         jsr    _LVOCheckIO(a6)        ;was it the SerReqptr?
  381.             beq.s    noSERIAL
  382.             jsr    _LVOWaitIO(a6)        ;SERIAL did it: cleanup serial
  383.  
  384.             lea    TimeIO(pc),a1    ;abort timer
  385.             jsr    _LVOAbortIO(a6)
  386.             lea    TimeIO(pc),a1
  387.         jsr    _LVOWaitIO(a6)    ;cleanup timer
  388.  
  389.             lea    SerIO(pc),a1
  390.             move.l    IO_ACTUAL(a1),d0 ;probably the IO_ACTUAL = # of asked bytes
  391.             rts
  392.  
  393.         cnop    0,4
  394. noSERIAL    lea    TimeIO(pc),a1    ;timeout?
  395.         move.l    4.w,a6
  396.         jsr    _LVOCheckIO(a6)
  397.         beq.s    noTIMER        ;something else did it...return to sleep
  398.         jsr    _LVOWaitIO(a6)
  399.  
  400.         lea    SerIO(pc),a1    ;abort serial
  401.         jsr    _LVOAbortIO(a6)
  402.             lea    SerIO(pc),a1
  403.         jsr    _LVOWaitIO(a6)
  404.  
  405.             lea    SerIO(pc),a1
  406.             move.l    IO_ACTUAL(a1),d0 ;probably IO_ACTUAL=0
  407.             rts
  408.  
  409. ;/* [xpr_swrite] ************************************************************/
  410. ;/*                                        */
  411. ;/* $Outputs:    a0 = char *buffer                        */
  412. ;/*         d0 = long size                            */
  413.  
  414.         cnop    0,4
  415. xpr_swrite:    lea    SerIO(pc),a1
  416.         move.w    #CMD_WRITE,IO_COMMAND(a1)
  417.         move.l    d0,IO_LENGTH(a1)
  418.         move.l    a0,IO_DATA(a1)
  419.         move.l    4.w,a6
  420.         jmp    _LVODoIO(a6)
  421.  
  422. ;/* [xpr_sflush] ************************************************************/
  423. ;/*                                        */
  424. ;/* $Outputs:    None (void)                            */
  425.  
  426.         cnop    0,4
  427. xpr_sflush:    lea    SerIO(pc),a1
  428.         move.w    #CMD_FLUSH,IO_COMMAND(a1)
  429.         move.l    4.w,a6
  430.         jmp    _LVODoIO(a6)
  431.  
  432.  
  433. ;/* [xpr_update] ************************************************************/
  434. ;/*                                        */
  435. ;/* $Outputs:    a0 = struct XPR_UPDATE *updatestruct                */
  436.  
  437.         cnop    0,4
  438. xpr_update    move.l    a5,-(sp)
  439.         lea    cb(pc),a5
  440.  
  441.         move.l    a0,a1
  442.         move.l    (a0),d5        ;update mask (what fields have changed)
  443.         btst    #1,d5
  444.         beq.s    noFileName
  445.             move.l  8(a1),a0    ;filename
  446.  
  447. noFileName    btst    #2,d5
  448.         beq.s    noFileSize
  449.         move.l  12(a1),TmpSiz-cb(a5)    ;file length
  450.  
  451. noFileSize    btst    #3,d5    
  452.         beq.s    noMSG
  453.         move.l  16(a1),d0    ;status msg
  454.  
  455. noMSG        btst    #4,d5
  456.         beq.s    noCPS
  457.             move.l  20(a1),d0    ;error msg
  458.  
  459. noCPS        btst    #7,d5
  460.         beq.s    noBYTES
  461.         move.l    32(a1),d0    ;byte position
  462.  
  463. noBYTES        btst    #14,d5
  464.         beq.s    noEXPECT
  465.         move.l  60(a1),d0    ;expect time
  466.  
  467. noEXPECT    btst    #15,d5
  468.         beq.s    noELAPSED
  469.         move.l  64(a1),d0    ;elapsed time
  470.  
  471. noELAPSED    btst    #16,d5
  472.         beq.s    noUPDATE
  473.         move.l  68(a1),TmpCps-cb(a5)    ;cps rate
  474.  
  475. noUPDATE    move.w    #$00f,$dff180
  476.  
  477.         move.l    (sp)+,a5
  478.         rts
  479.  
  480.  
  481. ;/* [xpr_chkabort] **********************************************************/
  482. ;/*                                        */
  483. ;/* $Outputs:    None (void)                            */
  484.  
  485.         cnop    0,4
  486. xpr_chkabort:    bsr.w     xpr_squery     ;vielleicht zu lang fuer isdn?
  487.         move.w     IO_STATUS(a1),d0
  488.         btst     #5,d0        ;CARRIER LOST?
  489.         bne.s     yoABORT
  490. noABORT        moveq    #0,d0         ;proceed with transmittion
  491.         rts
  492. yoABORT        moveq    #-1,d0        ;abort transmittion
  493.         rts
  494.  
  495.  
  496. ;/* [xpr_chkmisc] ***********************************************************/
  497. ;/*                                        */
  498. ;/* $Outputs:    None (void)                            */
  499.  
  500.         cnop    0,4
  501. xpr_chkmisc                     ;/* NOT IMPLEMENTED! */
  502.         rts
  503.  
  504.  
  505. ;/* [xpr_gets] **************************************************************/
  506. ;/*                                        */
  507. ;/* $Outputs:    a0 = char *prompt                        */
  508. ;/*         a1 = char *buffer                        */
  509.  
  510.         cnop    0,4
  511. xpr_gets                    ;/* NOT IMPLEMENTED! */
  512.         rts
  513.  
  514. ;/* [xpr_setserial] *********************************************************/
  515. ;/*                                        */
  516. ;/* $Outputs:    d0 = long newstatus                        */
  517.  
  518.         cnop    0,4
  519. xpr_setserial                    ;/* NOT IMPLEMENTED! */
  520.         rts
  521.  
  522.  
  523. ;/* [xpr_ffirst] ************************************************************/
  524. ;/*                                        */
  525. ;/* $Outputs:    a0 = char *buffer                        */
  526. ;/*         a1 = char *pattern                        */
  527.  
  528.         cnop    0,4
  529. xpr_ffirst    move.b    #" ",d0
  530.         tst.b    (a1)        ;"amixpr s ",0
  531.         beq.b    ffirst_null
  532.         cmp.b    (a1),d0        ;"amixpr s  ",0
  533.         beq.b    ffirst_null
  534. ffirst_loop    move.b    (a1)+,(a0)+
  535.         beq.b    ffirst_end    
  536.         cmp.b    (a1),d0
  537.         bne.b    ffirst_loop
  538. ffirst_end    sf.b    (a0)        ;terminate name with zero
  539.         move.l    a1,d0        ;wird fnext uebergeben in d0
  540.             rts
  541.         cnop    0,4
  542. ffirst_null    moveq    #0,d0    ;no file found
  543.             rts
  544.  
  545. ;/* [xpr_fnext] *************************************************************/
  546. ;/*                                        */
  547. ;/* $Outputs:    d0 = long oldstate                        */
  548. ;/*         a0 = char *buffer                        */
  549. ;/*         a1 = char *pattern                        */
  550.  
  551.         cnop    0,4
  552. xpr_fnext    move.l    d0,a1
  553.         move.b    #" ",d0
  554.         tst.b    (a1)+           ;                                  ^
  555.         beq.b    fnext_null    ;"oldname",0
  556.         tst.b    (a1)
  557.         beq.b    fnext_null    ;"oldname ",0
  558.         cmp.b    (a1),d0
  559.         beq.b    fnext_null      ;"oldname  "
  560. fnext_loop    move.b    (a1)+,(a0)+
  561.         beq.b    fnext_end    
  562.         cmp.b    (a1),d0        ;liest solange bis er ein space findet    
  563.         bne.b    fnext_loop
  564. fnext_end    sf.b    (a0)
  565.         move.l    a1,d0
  566.         rts
  567.         cnop    0,4
  568. fnext_null    moveq    #0,d0    ;no file found
  569.         rts
  570.  
  571. ;/* [xpr_finfo] *************************************************************/
  572. ;/*                                        */
  573. ;/* $Outputs:    a0 = char *filename                        */
  574. ;/*         d0 = long typeofinfo                        */
  575.  
  576.         cnop    0,4
  577. xpr_finfo:    move.l  d0,-(sp)
  578.         move.l  a0,d1
  579.         moveq  #-2,d2
  580.         move.l    DOSBase(pc),a6
  581.         jsr    _LVOLock(a6)
  582.             move.l  d0,d1
  583.             beq.s    finfo
  584.  
  585.             move.l  d0,-(sp)
  586.             move.l  d0,d1
  587.             lea    FIB(pc),a0
  588.             move.l    a0,d2
  589.         jsr    _LVOExamine(a6)
  590.         move.l  (sp)+,d1
  591.         jsr    _LVOUnLock(a6)
  592.  
  593.         move.l    (sp)+,d0
  594.         moveq    #2,d1
  595.         cmp.l    d1,d0
  596.         beq.b    finfo
  597.         subq.l    #1,d1
  598.         cmp.l    d1,d0
  599.         bne.b    finfo
  600.         lea     FIB(pc),a0
  601.         move.l  124(a0),d0    ;anzahl bytes
  602.         rts
  603.         cnop    0,4
  604. finfo        moveq    #0,d0
  605.         rts
  606.  
  607. ;/* [xpr_fseek] *************************************************************/
  608. ;/*                                        */
  609. ;/* $Outputs:    a0 = long fileptr                        */
  610. ;/*         d0 = long offset                        */
  611. ;/*         d1 = long origin                        */
  612.  
  613.         cnop    0,4
  614. xpr_fseek:    move.l    d1,d3        ;Modus offset_beginning/current/end
  615.         move.l    d0,d2        ;Abstand
  616.         move.l    a0,d1        ;Handle
  617.         subq.l    #1,d3
  618.         move.l    DOSBase(pc),a6
  619.         jsr    _LVOSeek(a6)
  620.         tst.l    d0
  621.         bmi.s    fseek1
  622.         moveq    #0,d0        ;0=success
  623. fseek1        rts
  624.  
  625.  
  626. ;/* [xpr_options] ***********************************************************/
  627. ;/*                                        */
  628. ;/* $Outputs:    d0 = long n                            */
  629. ;/*         a0 = struct xpr_option **opt                    */
  630.  
  631.         cnop    0,4
  632. xpr_options                    ;/* NOT IMPLEMENTED! */
  633.         rts
  634.  
  635. ;/* [xpr_unlink] ************************************************************/
  636. ;/*                                        */
  637. ;/* $Outputs:    a0 = char *filename                        */
  638.  
  639.         cnop    0,4
  640. xpr_unlink:    move.l  a0,d1
  641.         move.l    DOSBase(pc),a6
  642.         jsr    _LVODeleteFile(a6)
  643.         tst.l    d0
  644.         beq.s    unlink
  645.         moveq    #-1,d0
  646.         rts
  647.         cnop    0,4
  648. unlink        moveq    #0,d0
  649.         rts
  650.  
  651. ;/* [xpr_getptr] ************************************************************/
  652. ;/*                                        */
  653. ;/* $Outputs:    d0 = long type                            */
  654.  
  655.         cnop    0,4
  656. xpr_getptr                    ;/* NOT IMPLEMENTED! */
  657.         rts
  658.  
  659.         cnop    0,4
  660. relocflag    dc.w    -1
  661. XPR_IO        dc.l    0
  662.         dc.l    xpr_fopen-*    ;a pointer to this struct must be given
  663.         dc.l    xpr_fclose-*    ;whenever calling a xprlib function
  664.         dc.l    xpr_fread-*
  665.         dc.l    xpr_fwrite-*
  666.         dc.l    xpr_sread-*
  667.         dc.l    xpr_swrite-*
  668.         dc.l    xpr_sflush-*
  669.         dc.l    xpr_update-*
  670.         dc.l    xpr_chkabort-*
  671.         dc.l    0        ;not implemented
  672.         dc.l    0        ;not implemented
  673.         dc.l    0        ;not implemented
  674.         dc.l    xpr_ffirst-*
  675.         dc.l    xpr_fnext-*
  676.         dc.l    xpr_finfo-*
  677.         dc.l    xpr_fseek-*
  678.         dc.l    0        ;4;alle 4 EXT fields programmiert
  679.         dc.l    0
  680.         dc.l    xpr_options-*    ;EXT1 - not implemented
  681.         dc.l    xpr_unlink-*    ;EXT2
  682.         dc.l    xpr_squery-*    ;EXT3
  683.         dc.l    xpr_getptr-*    ;EXT4 - not implemented
  684.         dc.l    0,0,0,0
  685.         cnop    0,4
  686. DTBase        ds.l    1
  687. DOSBase        ds.l    1
  688. XPRBase        ds.l    1
  689. TmpCps        ds.l    1
  690. TmpEff        ds.l    1
  691. TmpTim        ds.l    1
  692. TmpSiz        ds.l    1
  693. IO_DataPt    ds.l    1
  694. IO_Size        ds.l    1
  695. IO_TimeOut    ds.l    1
  696. SerIO        ds.b    96        ;IOExtSer  Alloc for Message and Replyports
  697. SerReply    ds.b    48
  698. TimeIO        ds.b    48
  699. TimeReply    ds.b    48
  700.         cnop    0,4        ;*MUST* be longword aligned!
  701. FIB        ds.b    260        ;file-info-block alloc
  702.         even
  703. timer_name    dc.b    'timer.device',0
  704.